package com.itheima.aopanno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component("myAspect")
@Aspect //标注当前类是一个切面类
public class MyAspect {
    @Before(value = "execution(*  com.itheima.aopanno.*.*(..))")
    public void before(){
        System.out.println("前置增强");
    }
    public void afterReturning(){
        System.out.println("后置增强");
    }
    public void after(){
        System.out.println("最终增强");
    }
    @Around("pointcut()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕增强前");
        proceedingJoinPoint.proceed();
        System.out.println("环绕增强后");
    }

    //抽取切点表达式
    //定义切点表达式
    @Pointcut("execution(*  com.itheima.aopanno.*.*(..))")
    public void pointcut(){
    }
}
